<!doctype html>
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>教师界面</title>
<meta name="description" content="这是教师主页">
<meta name="keywords" content="index">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="../img/lysf.ico">
<link rel="stylesheet" href="../amazeui/css/amazeui.min.css" />
<link rel="stylesheet" href="css/admin.css">
<link rel="stylesheet" href="css/app.css">
</head>

<body style="margin-left: 10px; overflow: hidden;">

	<div id="ref_page" class="am-g">
	
	    <div class="tpl-content-page-title" style="margin-bottom: 10px;">申报课题</div>
		<div class="am-panel am-panel-default">
			<div class="am-panel-bd am-scrollable-horizontal">
				
				<div class="am-u-sm-12">
                            <form class="am-form">
                                <table class="am-table am-table-centered am-table-striped am-table-hover table-main">
                                    <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>课题名</th>
                                            <th>课题描述</th>
                                            <th>课题来源</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tbody">
                                      <tr>
                                            <td>1</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio1" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio1" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio1" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio1" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>2</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio2" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio2" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio2" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio2" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>3</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio3" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio3" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio3" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio3" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>4</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio4" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio4" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio40" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio4" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>5</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio5" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio5" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio5" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio5" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>6</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio6" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio6" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio6" value=3 data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio6" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>7</td>
                                            <td><input type="text"/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio7" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio7" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio70" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio7" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>8</td>
                                            <td><input type="text" id="user" name="user" required/></td>
                                            <td><textarea style="height: 36.8px;"></textarea></td>
                                            <td>
	                                        <label class="am-radio-inline">
												    <input type="radio" name="radio8" value="2" data-am-ucheck>学生拟定
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio8" value="1" data-am-ucheck checked>教师建议
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio8" value="3" data-am-ucheck>企业和社会征集
											</label>
											<label class="am-radio-inline">
												    <input type="radio" name="radio8" value="4" data-am-ucheck>科研单位提供
											</label>
											</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs am-text-secondary update"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                        <button type="button" disabled class="am-btn am-btn-default am-btn-xs yes" ><span class="am-icon-check"></span> 提交</button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
			</div>
		</div>
	</div>
	
<div class="am-modal am-modal-alert" tabindex="-1" id="edit-modal">
  <div class="am-modal-dialog" style="width: 750px;">
    <div class="am-modal-hd">课程描述
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd" id="edit_model_bd" style="text-align: left;"></div>
  <div class="am-modal-footer">
      <span class="am-modal-btn" id="edit_model_btn">确定</span>
  </div>
</div>
</div>

	<script src="../js/jquery.min.js"></script>
	<script src="../amazeui/js/amazeui.min.js"></script>
	<script type="text/javascript" src="../js/wangEditor.min.js"></script>
	<script type="text/javascript">
		$(function() {
			
			//课题描述编辑器
			$('textarea').focus(function(){
			  var this_textarea=$(this);
			  $('#edit_model_bd').empty();
			  $('#edit-modal').modal({
				  'closeViaDimmer':false,
			  });
			  $('#edit-modal').modal('open');
			  
			  $('#edit_model_bd').append($('<div>').attr('id','editor'));
			  var E = window.wangEditor;
 	       	  var editor = new E('#editor');
			  if($(this_textarea).val()!=''){
				  $('#editor').append($('<p>').text($(this_textarea).val()));
			  }
			  editor.create();
			  $('#edit_model_btn').click(function(){
				  this_textarea.html(editor.txt.text());
			   });
		  });
			
			//监听输入
			$('input[type=text]').bind('input propertychange',function(){
				if($(this).val()!=''){
					$(this).parent().parent().find('td:last').find('div div button').eq(1).removeAttr('disabled');
				}else{
					$(this).parent().parent().find('td:last').find('div div button').eq(1).attr('disabled','disabled');
				}
			});
			
			$.get('/graduation/projectController/getProjectByTeacherId',function(data){
				for(var i=0;i<data.length;i++){
					var tr=$('#tbody').find('tr').eq(i);
					tr.find('td').eq(1).find('input').val(data[i].projectName).attr('disabled','disabled');
					tr.find('td').eq(2).find('textarea').val(data[i].projectDescribe).attr('disabled','disabled');
					var radio=tr.find('td').eq(3).find('input[type=radio]').removeAttr('checked');
					radio.each(function(index,value){
						if($(this).val()==data[i].projectFromId){
							$(this).attr('checked','checked');
						}
					});
					tr.append($('<input>').attr('type','hidden').val(data[i].projectId));
					tr.find('td').eq(4).find('.update').removeAttr('disabled');
					tr.find('td').eq(4).find('.yes').attr('disabled','disabled');
				}
			});
			
			$('.yes').click(function(){
				var btn=$(this);
				var tr=btn.parent().parent().parent().parent();
				var project_name=tr.find('td').eq(1).find('input').val();
				var project_describe=tr.find('td').eq(2).find('textarea').val();
				if(project_name==''){
					return false;
				}
				var project_from_id=tr.find('td').eq(3).find('input:checked').val();
				var projectId=tr.find('input[type=hidden]').val();
				$.post('/graduation/projectController/insertSelective',{
					projectName:project_name,
					projectDescribe:project_describe,
					projectFromId:project_from_id,
					projectId:projectId
				},function(data){
					btn.attr('disabled','disabled');
					btn.parent().find('.update').removeAttr('disabled');
					tr.find('td').eq(1).find('input').attr('disabled','disabled');
					tr.find('td').eq(2).find('textarea').attr('disabled','disabled');
				})
			});
			
			$('.update').click(function(){
				var btn=$(this);
				var tr=btn.parent().parent().parent().parent();
				btn.attr('disabled','disabled');
				btn.parent().find('.yes').removeAttr('disabled');
				tr.find('td').eq(1).find('input').removeAttr('disabled');
				tr.find('td').eq(2).find('textarea').removeAttr('disabled');
			});
			
		});
	</script>
</body>

</html>